package com.ruoyi.zsyh.controller.applet.wechat.main;


import com.ruoyi.zsyh.controller.applet.wechat.menu.Button;
import com.ruoyi.zsyh.controller.applet.wechat.menu.ComplexButton;
import com.ruoyi.zsyh.controller.applet.wechat.menu.Menu;
import com.ruoyi.zsyh.controller.applet.wechat.menu.ViewButton;
import com.ruoyi.zsyh.controller.applet.wechat.util.MenuUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 菜单管理器类
 * 
 * @author
 */
public class MenuManager {

	/**
	 * 组装菜单数据
	 * 
	 * @return
	 */
	private static Logger log = LoggerFactory.getLogger(MenuManager.class);
	public static Menu getMenu() {
//		ClickButton btn11 = new ClickButton();
//		btn11.setName("加盟介绍");
//		btn11.setType("click");
//		btn11.setKey("11");


//		ViewButton wx11 = new ViewButton();
//		wx11.setName("加盟介绍");
//		wx11.setType("view");
//		wx11.setUrl("https://www.zzzsyh.com/index.html#/joining");
//		ViewButton wx12 = new ViewButton();
//		wx12.setName("App下载");
//		wx12.setType("view");
//		wx12.setUrl("https://www.zzzsyh.com/index.html#/app");
//
//
//		ComplexButton mainBtn3 = new ComplexButton();
//		mainBtn3.setName("加盟登录");
//		mainBtn3.setSub_button(new Button[] {wx11,wx12 });

		ViewButton wx11 = new ViewButton();
		wx11.setName("扫码安装");
		wx11.setType("view");
		wx11.setUrl("https://xcx.zzzsyh.com/indexWx.html#/scan");
		ViewButton wx12 = new ViewButton();
		wx12.setName("扫码申请");
		wx12.setType("view");
		wx12.setUrl("https://xcx.zzzsyh.com/indexWx.html#/scanMoney");
		ViewButton wx13 = new ViewButton();
		wx13.setName("安装记录");
		wx13.setType("view");
		wx13.setUrl("https://www.zzzsyh.com/parts.html#/orderlistInstall");
		ViewButton wx14 = new ViewButton();
		wx14.setName("申请记录");
		wx14.setType("view");
		wx14.setUrl("https://xcx.zzzsyh.com/indexWx.html#/orderlist");


		ComplexButton mainBtn3 = new ComplexButton();
		mainBtn3.setName("配件补助金");
		mainBtn3.setSub_button(new Button[] {wx11, wx12, wx14});



		ViewButton wx = new ViewButton();
		wx.setName("一键下单");
		wx.setType("view");
		wx.setUrl("https://www.zzzsyh.com/index.html#/first");
		ViewButton wx2 = new ViewButton();
		wx2.setName("订单跟踪");
		wx2.setType("view");
		wx2.setUrl("https://www.zzzsyh.com/index.html#/order");
		ViewButton wx3 = new ViewButton();
		wx3.setName("个人中心");
		wx3.setType("view");
		wx3.setUrl("https://www.zzzsyh.com/index.html#/myzoe");
		ViewButton wx4 = new ViewButton();
		wx4.setName("识别配件");
		wx4.setType("view");
		wx4.setUrl("https://www.zzzsyh.com/index.html#/richscan");
		ComplexButton mainBtn1 = new ComplexButton();
		mainBtn1.setName("服务中心");
		mainBtn1.setSub_button(new Button[] {wx,wx2,wx3,wx4});



		ViewButton fjmd = new ViewButton();
		fjmd.setName("申请推广码");
		fjmd.setType("view");
		fjmd.setUrl("https://www.zzzsyh.com/index.html#/loginEwm");
		ViewButton fjmd2 = new ViewButton();
		fjmd2.setName("我的收益");
		fjmd2.setType("view");
		fjmd2.setUrl("https://www.zzzsyh.com/index.html#/onlyEarnings");
		ViewButton fjmd3 = new ViewButton();
		fjmd3.setName("预约整机服务");
		fjmd3.setType("view");
		fjmd3.setUrl("http://xcx.zzzsyh.com/applet/zsyh/wxGZHUser/login");


		ComplexButton mainBtn2 = new ComplexButton();
		mainBtn2.setName("申请推广码");
		mainBtn2.setSub_button(new Button[] {fjmd,fjmd2,fjmd3 });


		ViewButton zjsh = new ViewButton();
		zjsh.setName("安装登记");
		zjsh.setType("view");
		zjsh.setUrl("https://xcx.zzzsyh.com/machine.html#/install");

		ViewButton zjsh1 = new ViewButton();
		zjsh1.setName("售后报修");
		zjsh1.setType("view");
		zjsh1.setUrl("https://xcx.zzzsyh.com/machine.html#/");

		ComplexButton mainBtn4 = new ComplexButton();
		mainBtn4.setName("整机售后");
		mainBtn4.setSub_button(new Button[] {zjsh, zjsh1});

		ViewButton fjmd001 = new ViewButton();//跳转到小程序
		fjmd001.setName("加入接单");
		fjmd001.setType("miniprogram");
		fjmd001.setUrl("http://mp.weixin.qq.com");
		fjmd001.setAppid("wxc2298573abab5690");
		fjmd001.setPagepath("pages/home/index/index");

		/**
		 * 这是公众号目前的菜单结构，每个一级菜单都有二级菜单项<br>
		 * 
		 * 在某个一级菜单下没有二级菜单的情况，menu该如何定义呢？<br>
		 * 比如，第三个一级菜单项不是“更多体验”，而直接是“幽默笑话”，那么menu应该这样定义：<br>
		 * menu.setButton(new Button[] { mainBtn1, mainBtn2, btn33 });
		 */
		Menu menu = new Menu();
		menu.setButton(new Button[] { fjmd001,mainBtn3, mainBtn4 });
		return menu;
	}

	public static void main(String[] args) {
		// 调用接口创建菜单
		//https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxf7cad0b2743a6eaf&secret=481b3c0704cdd135c1ea4f0987487d2f
		boolean result = MenuUtil
				.createMenu(getMenu(), "83_Cg9KeahwnEbVEOlJV1jmC8lHibloZvvhvU3-8IQDgfSsb0PE7WPV_DSfJqjlvp6IN_djGwjVwFSMzyek4DMYXKOLggE3Gpv0MX0YcqiB63kAbTEMFBwSjRLPp7wZXIbADADBM");

		// 判断菜单创建结果
		if (result)
			log.info("菜单创建成功！");
		else
			log.info("菜单创建失败，错误码：" + result);
	}

}
